package demo1;

public class Student implements Comparable<Student>{
    public String name;
    public int age;
    public double score;

    public Student(String name, int age, double score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student1{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        if(this.age>o.age) {
            return 1;
        }else  if(this.age<o.age){
            return -1;
        }else return 0;
        //return Integer.compare(this.age, o.age);
        //return this.age - o.age;
    }
}
